package com.giteelou.gitee.sdjl01.serv;

import com.giteelou.gitee.sdjl01.entity.City;
import com.giteelou.gitee.sdjl01.repo.CityCrudRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Service
public class CityService {

    @Autowired
    CityCrudRepository repository;

    @Transactional
    public void update(Long id) {
        Optional<City> optionalCity = repository.findById(id);
        optionalCity.ifPresent(city -> {
            city.setName(city.getName() + "a");
        });
    }

}
